﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Tenancy.Helper;

namespace Tenancy.Server
{
    /// <summary>
    /// Hbung_Calculatedis 的摘要说明
    /// </summary>
    public class Hbung_Calculatedis : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //起始坐标
            string Hb_StartZB = context.Request.Params["SZB"];
            if (string.IsNullOrEmpty(Hb_StartZB))
            {
                context.Response.Write(GenerClass.SetParamErrorJsData("SZB不能为空"));
                return;
            }
            //目的地坐标
            string Hb_EndZB = context.Request.Params["EZB"];
            if (string.IsNullOrEmpty(Hb_EndZB))
            {
                context.Response.Write(GenerClass.SetParamErrorJsData("EZB不能为空"));
                return;
            }
            string param = "http://api.map.baidu.com/routematrix/v2/driving?output=json&origins=" + Hb_StartZB + "&destinations=" + Hb_EndZB + "&ak=VDNGYTVD6n9vYRIlBQbHYjnYnqPBvbpf";
            string outStr = GenerClass.HttpGet(param);//只能用get请求，不能使用post

            context.Response.Write(outStr);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}